import java.util.Random;
import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        Random random = new Random();
        int computer = random.nextInt(100) + 1;
        Scanner scanner = new Scanner(System.in);
        String YN="";
        boolean play=true;
        while(play){
            System.out.println("请输入您猜测的数字");
            for (int i = 6; i >=0; i--) {
            int user = scanner.nextInt();
            if (computer == user) {
                System.out.println("恭喜您猜对了");
                break;
            } else {
                if (user > computer)
                    System.out.println("您猜大了");
                else
                    System.out.println("您猜小了");
                System.out.println("您还有"+i+"次机会");
            }
        }
        while (true){
            System.out.println("是否继续游戏 Y/N");
                YN = scanner.next();
            if (YN.equals("Y")||YN.equals("y"))break;
            else if(YN.equals("N")||YN.equals("n")){
                play=false;
                break;
            }else{
                System.out.println("输入错误，重新输入");
            }
    }}
    }
}
